package javacode.chapter07.homework;

public class Homework02 {
    public static void main(String[] args) {
        String[] strs = {"A", "B", "C", "D"};
        A02 a02 = new A02();
        System.out.println(a02.find("A", strs));
    }
}


//编写类A02，定义方法find，实现查找某字符串是否在字符串数组中，
//并返回索引，如果找不到，返回-1

class A02{
    int find(String str, String[] strs){
        for (int i = 0; i < strs.length; i++) {
            if (str.equals(strs[i])){
                return i;
            }
        }
        return -1;
    }
}
